//
//  LMTabBarController.m
//  LM
//
//  Created by Kien Tran on 1/24/13.
//  Copyright (c) 2013 Kien Tran. All rights reserved.
//

#import "LMTabBarController.h"

#import "LMConstant.h"
#import "LMHeartButton.h"
#import "LMSettingViewController.h"

@interface LMTabBarController () {
    UIButton *_plusButton;
    UIButton *_minusButton;
    LMHeartButton *_heartButton;
}

@end

@implementation LMTabBarController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
//    CGRect tabBarRect = self.tabBar.frame;
//    tabBarRect.origin = CGPointMake(0, 20);
//    
//    self.tabBar.frame = tabBarRect;
//    [self.tabBar setBackgroundImage:[UIImage imageNamed:kIMAGE_BG_NAV]];
//    for (UIView *view in self.tabBar.subviews) {
//       // if ([NSStringFromClass([view class]) isEqualToString:@"_UITabBarBackgroundView"]) {
//            [view removeFromSuperview];
//       // }
//    }
//    
//    
//    //Set bg
//    [self.tabBar setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:kIMAGE_BG_NAV]]];
//    
//    // bottom button
//    UIImage *plus = [UIImage imageNamed:kIMAGE_BG_PLUS];
//    UIImage *activePlus = [UIImage imageNamed:kIMAGE_BG_PLUS_ACTIVE];
//    
//    UIImage *minus = [UIImage imageNamed:kIMAGE_BG_MINUS];
//    UIImage *activeMinus = [UIImage imageNamed:kIMAGE_BG_MINUS_ACTIVE];
//    
//    _plusButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [_plusButton setImage:plus forState:UIControlStateNormal];
//    [_plusButton setImage:activePlus forState:UIControlStateSelected];
//    
//    _minusButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [_minusButton setImage:minus forState:UIControlStateNormal];
//    [_minusButton setImage:activeMinus forState:UIControlStateSelected];
//    
//    CGRect plusRect = CGRectMake(0, kDIMESSION_VIEW_HEIGHT - 28, 163, 27);
//    _plusButton.frame = plusRect;
//    
//    CGRect minusRect = CGRectMake(155, kDIMESSION_VIEW_HEIGHT - 28, 165, 27);
//    _minusButton.frame = minusRect;
//    
//    [self.view addSubview:_plusButton];
//    [self.view addSubview:_minusButton];
//    
//    // Set heart button
//    UIImageView *heartBG = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kIMAGE_BG_HEART]];
//    CGRect heartBGRect = CGRectMake(0, 20, 116, 83);
//    [heartBG setFrame:heartBGRect];
//    [heartBG setCenter:self.view.center];
//    heartBGRect = heartBG.frame;
//    heartBGRect.origin.y = 20;
//    heartBG.frame = heartBGRect;
//    [self.view addSubview:heartBG];
//    
//    _heartButton= [LMHeartButton buttonWithType:UIButtonTypeCustom];
//    _heartButton.valuePercent = 80;
//    
//    [_heartButton setCenter:self.view.center];
//    CGRect heartRect = _heartButton.frame;
//    heartRect.origin.y = 21;
//    _heartButton.frame = heartRect;
//    
//    [self.view addSubview:_heartButton];
//    
//    // Set view bg
//    [self.view setBackgroundColor:kCOLOR_BG];
//    
//    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    [rightButton setTitle:@"Setting" forState:UIControlStateNormal];
//    [rightButton setFrame:CGRectMake(241, 24, 72, 37)];
//    [rightButton addTarget:self action:@selector(touchRightBarButton:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:rightButton];
//    
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
//    
////    for (UIView *viewController in self.view.subviews) {
////        CGRect rect = [viewController.view frame];
////        rect.origin.y = self.tabBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height + 50;
////        rect.size.height = self.view.frame.size.height - rect.origin.y;
////        
////        [viewController.view setFrame:rect];
////        NSLog(@"%@", viewController);
////    }
//
//    [self.tabBar setHidden:YES];
    }

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)touchRightBarButton:(id)sender {
    [self setSelectedIndex:1];
    [self.tabBar setHidden:NO];
}
@end
